<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <thead>
        <tr>
            <th width="8%">Số thứ tự</th>
            <th>Ảnh sản phẩm</th>
            <th>Tên sản phẩm</th>
            <th>Mô tả sản phẩm</th>
            <th>Ngày đăng</th>
            <th>Người đăng</th>
            <th>Loại sản phẩm</th>
            <th>Giá bán</th>
            <th>Thao tác</th>
        </tr>
    </thead>
    <tbody id="noidung_ajax">

        <?php
            for($i=0; $i<count($sanpham); $i++){
                $noi_dung =  $sanpham[$i]['MoTa'];
                $link_anh = base_url()."images/product/".$sanpham[$i]['AnhSanPham'];
                if(strlen($noi_dung)>=80){
                    $tom_tat = substr($noi_dung, 0, 80);
                    $index = strrpos($tom_tat, " " );
                    $tom_tat = substr($tom_tat, 0, $index+1)."...";
                }else{
                    $tom_tat = $noi_dung;
                }
                $link_xoa = base_url()."index.php/qlsp_admin_controller/deleteProduct/".$sanpham[$i]['MaSanPham'];

                echo"<tr class='gradeU'>";
                    echo"<td align='center'>".($i+1)."</td>";
                    echo"<td align='center'><img src=".$link_anh." height='100' width='100'/></td>";
                    echo"<td><b>".$sanpham[$i]['TenSanPham']."</b></td>";
                    echo"<td><p title='$noi_dung'>".$tom_tat."</p></td>";
                    echo"<td align='center'>".$sanpham[$i]['NgayDang']."</td>";
					echo"<td align='center'>".$sanpham[$i]['TenDangNhap']."</td>";
                    echo"<td align='center'>".$sanpham[$i]['TenLoaiSP']."</td>";
                    echo"<td class='center' width='100'>".$sanpham[$i]['GiaBan']." VNĐ</td>";
                   echo"<td class='center'><a href='$link_xoa' title='Xóa sản phẩm' onclick='return show_confirm();'><img class='delBtn' src='".base_url()."images/trash.png' height='32' width='32' ></a></td>";
                echo"</tr>";
            }
        ?>
    </tbody>
</table>
<script type="text/javascript" src="<?=base_url()?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?=base_url()?>js/jquery.dataTables.min.js"></script>

<script type="text/javascript">
		$('#example').dataTable( {
			"aaSorting":[[4,'desc']],
			"bJQueryUI": true,
			"sPaginationType": "full_numbers",
			"aoColumns": [{"bSearchable": false, "bSortable": false},
						  {"bSearchable": false, "bSortable": false},
			              null,
						  {"bSortable": false},
						  {"bSortable": false},
						  {"bSortable": false},
			              {"bSearchable": false},
			              null,
			              {"bSearchable": false, "bSortable": false}]
		});
		
		$('.editBtn').hover(function(){
			$(this).attr('src','<?=base_url()?>images/edit_hover.png');
		}, function(){
			$(this).attr('src','<?=base_url()?>images/edit.png');
		});
		$('.delBtn').hover(function(){
			$(this).attr('src','<?=base_url()?>images/trash_hover.png');
		}, function(){
			$(this).attr('src','<?=base_url()?>images/trash.png');
		});

</script>
